/**
 * @author Shine Chen
 * @date 2011.10.28
 */

package org.mini.templates
{
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class AbstractBase extends MovieClip
	{
		public function AbstractBase()
		{
			super();
			
			addEventListener(Event.ADDED_TO_STAGE, addToStage ,false ,0 ,true);
		}
		
		protected function addToStage(e:Event=null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, addToStage);
			addEventListener(Event.REMOVED_FROM_STAGE, removeToStage ,false ,0 ,true);
		}
		
		protected function removeToStage(e:Event=null):void
		{
			dispose();
		}
		
		public function dispose():void
		{
			removeEventListener(Event.ADDED_TO_STAGE, addToStage);
			removeEventListener(Event.REMOVED_FROM_STAGE, dispose);
		}
	}
}